﻿using System;
using System.Runtime.Serialization;

namespace Robin.LightNing.Core
{
    /// <summary>
    /// 
    /// </summary>
    /// <typeparam name="C"></typeparam>
    [DataContract]
    [Serializable]
    public class rbCollectionWCFPacket<C> where C : rbEntityCollectionBase
    {
        /// <summary>
        /// 
        /// </summary>
        [DataMember]
        public C Collection;
        /// <summary>
        /// 
        /// </summary>
        /// <param name="context"></param>
        [OnSerializingAttribute]
        internal void OnSerializing(StreamingContext context)
        {
            if (Collection != null)
            {
                Collection.CombineDeletedEntities();
            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="context"></param>
        [OnDeserializedAttribute]
        internal void OnDeserialized(StreamingContext context)
        {
            if (Collection != null)
            {
                Collection.SeparateDeletedEntities();
            }
        }
    }
}
